package com.smbe.netty.protobuf;

import com.smbe.pb.demo.DateInfo;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * <p>Title: </p>
 * <p>Company:misspao </p>
 *
 * @author: buwenmin
 * @Date: Create in 23:28 2019/2/19
 * @Description:
 */
public class MyServerHandel extends SimpleChannelInboundHandler<DateInfo.Message> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, DateInfo.Message msg) throws Exception {

        DateInfo.Message.DataType dataType = msg.getDataType();
        if(dataType== DateInfo.Message.DataType.PersonType){
            final DateInfo.Person person = msg.getPerson();
            System.out.println(person.getName());
            System.out.println(person.getAge());
            System.out.println(person.getAddress());
        }else if(dataType== DateInfo.Message.DataType.DogType){
            final DateInfo.Dog dog = msg.getDog();
            System.out.println(dog.getAge());
            System.out.println(dog.getName());

        }else{
            final DateInfo.Cat cat = msg.getCat();
            System.out.println(cat.getAddress());
            System.out.println(cat.getName());

        }




    }
}
